/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.mallsite.modules.shop.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.idgen.IdGen;
import com.jeesite.common.service.TreeService;
import com.mallsite.modules.shop.entity.GoodsCategory;
import com.mallsite.modules.shop.dao.GoodsCategoryDao;
import com.jeesite.modules.file.utils.FileUploadUtils;

/**
 * 商品分类Service
 * @author ruyang
 * @version 2020-12-04
 */
@Service
@Transactional(readOnly=true)
public class GoodsCategoryService extends TreeService<GoodsCategoryDao, GoodsCategory> {
	
	/**
	 * 获取单条数据
	 * @param goodsCategory
	 * @return
	 */
	@Override
	public GoodsCategory get(GoodsCategory goodsCategory) {
		return super.get(goodsCategory);
	}
	
	/**
	 * 查询列表数据
	 * @param goodsCategory
	 * @return
	 */
	@Override
	public List<GoodsCategory> findList(GoodsCategory goodsCategory) {
		return super.findList(goodsCategory);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param goodsCategory
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(GoodsCategory goodsCategory) {
		if (goodsCategory.getIsNewRecord()){
			goodsCategory.setCategoryCode(IdGen.nextId());
		}
		super.save(goodsCategory);
		// 保存上传图片
		FileUploadUtils.saveFileUpload(goodsCategory.getId(), "categoryLogo_image");
		FileUploadUtils.saveFileUpload(goodsCategory.getId(), "categoryCover_image");
	}
	
	/**
	 * 更新状态
	 * @param goodsCategory
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(GoodsCategory goodsCategory) {
		super.updateStatus(goodsCategory);
	}
	
	/**
	 * 删除数据
	 * @param goodsCategory
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(GoodsCategory goodsCategory) {
		super.delete(goodsCategory);
	}
	
}